﻿namespace SampleApplication.CoffeeShopSample.Dependencies.Application
{
    #region Usings

    using Implementation.Domain;
    using System.Diagnostics.CodeAnalysis;

    #endregion Usings

    public class Bootstrap : IBootstrap
    {
        private readonly IConsole console;
        private readonly IMenuWriter menuWriter;
        private readonly ICommandParser commandParser;

        public Bootstrap(IConsole console, IMenuWriter menuWriter, ICommandParser commandParser)
        {
            this.console = console;
            this.menuWriter = menuWriter;
            this.commandParser = commandParser;
        }

        /// <summary>
        /// Execute the application.
        /// </summary>
        [ExcludeFromCodeCoverage]
        public void Run()
        {
            while (true)
            {
                console.Clear();

                menuWriter.Write();

                var command = commandParser.Parse(console.ReadLine());

                command.Execute();

                console.WaitForAnyKeyPressed();
            }
        }
    }
}